package com.eastfair.messagecenter.pending;


import cn.hutool.core.collection.CollUtil;
import com.eastfair.messagecenter.domain.TaskInfo;
import com.eastfair.messagecenter.handler.HandlerHolder;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Task 执行器
 * 0.丢弃消息
 * 2.屏蔽消息
 * 2.通用去重功能
 * 3.发送消息
 *
 * @author ligang
 */
@Data
@Accessors(chain = true)
@Slf4j
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class Task implements Runnable {

    @Autowired
    private HandlerHolder handlerHolder;

    private TaskInfo taskInfo;


    @Override
    public void run() {

        //发送消息
        handlerHolder.route(taskInfo.getSendChannel()).doHandler(taskInfo);

    }
}
